{% extends 'mom.html' %}    <!-- 模板继承 -->
{% load static %}   <!-- 加载静态资源 -->

{% block content %}
    <div>
        <h1>管理员 <span class="label label-default">欢迎</span></h1>

        <div class="panel panel-default">
            <!-- Default panel contents -->
            <h4>
                <div class="panel-heading">人员信息</div>
            </h4>

            <!-- Table -->
            <table class="table">
                <tr>
                    <td>ID</td>
                    <td>NAME</td>
                    <td>PASSWORD</td>
                    <td>部门</td>
                    <td>操作</td>
                </tr>
                {% for i in inf %}
                    <tr>
                        <td>{{ i.id }}</td>
                        <td>{{ i.name }}</td>
                        <td>{{ i.password }}</td>
                        <td>{{ i.deparment.title }}</td>
                        <td><a href="/admin/?del={{ i.id }}">删除</a></td>
                    </tr>
                {% endfor %}
            </table>
        </div>

        <div class="panel panel-default">
            <!-- Default panel contents -->
            <h4>
                <div class="panel-heading">部门信息</div>
            </h4>

            <!-- Table -->
            <table class="table">
                <tr>
                    <td>ID</td>
                    <td>部门</td>
                    <td>操作</td>
                </tr>
                {% for i in depa %}
                    <tr>
                        <td>{{ i.id }}</td>
                        <td>{{ i.title }}</td>
                        <td><a href="/admin/?del_ap={{ i.id }}">删除</a></td>
                    </tr>
                {% endfor %}
            </table>
        </div>

        <hr/>
        <h4>添加人员</h4>
        <form action="/admin/?pos=1" method="post">
            {% csrf_token %}
            <div class="input-group">
                <span class="input-group-addon" id="sizing-addon1">@</span>
                <input type="text" class="form-control" name="username" placeholder="用户名"
                       aria-describedby="sizing-addon1"/>
            </div>

            <div class="input-group">
                <span class="input-group-addon" id="sizing-addon2">@</span>
                <input type="password" name="password" class="form-control" placeholder="密码"
                       aria-describedby="sizing-addon2">
            </div>
            <div class="form-group">
                <select name="deparment">
                    <lable>部门</lable>
                        {% for i in depa %}
                            <option value="{{ i.id }}">{{ i.title }}</option>
                        {% endfor %}
                </select>
            </div>
            <br/><br/>
            <div class="btn-group" role="group" aria-label="...">
                <input type="submit" class="btn btn-default" value="提交"/>
            </div>
        </form>

        <h4>添加部门</h4>
        <form action="/admin/?pos=2" method="post">
            {% csrf_token %}
            <div class="input-group">
                <span class="input-group-addon" id="sizing-addon1">@</span>
                <input type="text" class="form-control" name="name" placeholder="部门"
                       aria-describedby="sizing-addon1"/>
            </div>

            <br/><br/>
            <div class="btn-group" role="group" aria-label="...">
                <input type="submit" class="btn btn-default" value="提交"/>
            </div>
        </form>

        <div class="alert alert-danger">{{ err }}</div>
    </div>
{% endblock %}